<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>定位</title>
    <style>
.w{
    margin: 10px auto;
width: 500px;
height: 1000px;
background-color: pink;
    }
.fixed{
    position: fixed;
    top:50px;
    left:50%;
    margin-left: 260px;
    width: 50px;
    height: 80px;
    background-color: lightblue;
}
    </style>
    
</head>
<body>
    <div class="fixed"></div>
    <div class="w"></div>
</body>
</html>